home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3n / recv.z / recv
Encoding:
Text File  |  2002-10-03  |  8.2 KB  |  131 lines

  1.  
  2.  
  3.  
  4. rrrreeeeccccvvvv((((3333NNNN))))                                                              rrrreeeeccccvvvv((((3333NNNN))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      _rrrr_eeee_cccc_vvvv_,,,, _rrrr_eeee_cccc_vvvv_ffff_rrrr_oooo_mmmm_,,,, _rrrr_eeee_cccc_vvvv_mmmm_ssss_gggg - receive a message from a socket
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      #include <sys/types.h>
  13.      int recv(int s, char *buf, int len, int flags);
  14.      int recvfrom(int s, char *buf, int len, int flags, caddr_t from,
  15.          int *fromlen);
  16.      int recvmsg(int s, struct msghdr *msg, int flags);
  17.  
  18. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  19.      _s is a socket created with _ssss_oooo_cccc_kkkk_eeee_tttt.  _rrrr_eeee_cccc_vvvv, _rrrr_eeee_cccc_vvvv_ffff_rrrr_oooo_mmmm, and _rrrr_eeee_cccc_vvvv_mmmm_ssss_gggg are used
  20.      to receive messages from another socket.  _rrrr_eeee_cccc_vvvv may be used only on a
  21.      _c_o_n_n_e_c_t_e_d socket [see _cccc_oooo_nnnn_nnnn_eeee_cccc_tttt(3N)], while _rrrr_eeee_cccc_vvvv_ffff_rrrr_oooo_mmmm and _rrrr_eeee_cccc_vvvv_mmmm_ssss_gggg may be
  22.      used to receive data on a socket whether it is in a connected state or
  23.      not.
  24.  
  25.      If _f_r_o_m is not a _NNNN_UUUU_LLLL_LLLL pointer, the source address of the message is
  26.      filled in.  _f_r_o_m_l_e_n is a value-result parameter, initialized to the size
  27.      of the buffer associated with _f_r_o_m, and modified on return to indicate
  28.      the actual size of the address stored there.  The length of the message
  29.      is returned.  If a message is too long to fit in the supplied buffer,
  30.      excess bytes may be discarded depending on the type of socket the message
  31.      is received from [see _ssss_oooo_cccc_kkkk_eeee_tttt(3N)].
  32.  
  33.      If no messages are available at the socket, the receive call waits for a
  34.      message to arrive, unless the socket is nonblocking [see _ffff_cccc_nnnn_tttt_llll(2)] in
  35.      which case _----_1111 is returned with the external variable _eeee_rrrr_rrrr_nnnn_oooo set to
  36.      _EEEE_WWWW_OOOO_UUUU_LLLL_DDDD_BBBB_LLLL_OOOO_CCCC_KKKK.
  37.  
  38.      The _ssss_eeee_llll_eeee_cccc_tttt call may be used to determine when more data arrives.
  39.  
  40.      The _f_l_a_g_s parameter is formed by _OOOO_RRRRing one or more of the following:
  41.  
  42.      _MMMM_SSSS_GGGG______OOOO_OOOO_BBBB   Read any out-of-band data present on the socket rather than the
  43.                regular in-band data.
  44.  
  45.      _MMMM_SSSS_GGGG______PPPP_EEEE_EEEE_KKKK  Peek at the data present on the socket; the data is returned,
  46.                but not consumed, so that a subsequent receive operation will
  47.                see the same data.
  48.  
  49.      The _rrrr_eeee_cccc_vvvv_mmmm_ssss_gggg() call uses a _mmmm_ssss_gggg_hhhh_dddd_rrrr structure to minimize the number of
  50.      directly supplied parameters.  This structure is defined in _ssss_yyyy_ssss_////_ssss_oooo_cccc_kkkk_eeee_tttt_...._hhhh
  51.      and includes the following members:
  52.  
  53.           caddr_t      msg_name;         /* optional address */
  54.           int          msg_namelen;      /* size of address */
  55.           struct iovec *msg_iov;         /* scatter/gather array */
  56.           int          msg_iovlen;       /* # elements in msg_iov */
  57.           caddr_t      msg_accrights;    /* access rights sent/received */
  58.           int          msg_accrightslen;
  59.  
  60.  
  61.                                                                         PPPPaaaaggggeeee 1111
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68. rrrreeeeccccvvvv((((3333NNNN))))                                                              rrrreeeeccccvvvv((((3333NNNN))))
  69.  
  70.  
  71.  
  72.      Here _mmmm_ssss_gggg______nnnn_aaaa_mmmm_eeee and _mmmm_ssss_gggg______nnnn_aaaa_mmmm_eeee_llll_eeee_nnnn specify the destination address if the
  73.      socket is unconnected; _mmmm_ssss_gggg______nnnn_aaaa_mmmm_eeee may be given as a _NNNN_UUUU_LLLL_LLLL pointer if no
  74.      names are desired or required.  The _mmmm_ssss_gggg______iiii_oooo_vvvv and _mmmm_ssss_gggg______iiii_oooo_vvvv_llll_eeee_nnnn describe the
  75.      scatter-gather locations, as described in _rrrr_eeee_aaaa_dddd.  A buffer to receive any
  76.      access rights sent along with the message is specified in _mmmm_ssss_gggg______aaaa_cccc_cccc_rrrr_iiii_gggg_hhhh_tttt_ssss,
  77.      which has length _mmmm_ssss_gggg______aaaa_cccc_cccc_rrrr_iiii_gggg_hhhh_tttt_ssss_llll_eeee_nnnn.
  78.  
  79. RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEE
  80.      These calls return the number of bytes received, or _----_1111 if an error
  81.      occurred.
  82.  
  83. EEEERRRRRRRROOOORRRRSSSS
  84.      The calls fail if:
  85.  
  86.      _EEEE_BBBB_AAAA_DDDD_FFFF               _s is an invalid descriptor.
  87.  
  88.      _EEEE_NNNN_OOOO_TTTT_SSSS_OOOO_CCCC_KKKK            _s is a descriptor for a file, not a socket.
  89.  
  90.      _EEEE_IIII_NNNN_TTTT_RRRR               The operation was interrupted by delivery of a signal
  91.                          before any data was available to be received.
  92.  
  93.      _EEEE_WWWW_OOOO_UUUU_LLLL_DDDD_BBBB_LLLL_OOOO_CCCC_KKKK         The socket is marked non-blocking and the requested
  94.                          operation would block.
  95.  
  96.      _EEEE_NNNN_OOOO_MMMM_EEEE_MMMM              There was insufficient user memory available for the
  97.                          operation to complete.
  98.  
  99.      _EEEE_NNNN_OOOO_SSSS_RRRR               There were insufficient STREAMS resources available
  100.                          for the operation to complete.
  101.  
  102. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  103.      _ffff_cccc_nnnn_tttt_llll(2), _iiii_oooo_cccc_tttt_llll(2), _rrrr_eeee_aaaa_dddd(2), _cccc_oooo_nnnn_nnnn_eeee_cccc_tttt(3N), _gggg_eeee_tttt_ssss_oooo_cccc_kkkk_oooo_pppp_tttt(3N), _ssss_eeee_nnnn_dddd(3N),
  104.      _ssss_oooo_cccc_kkkk_eeee_tttt(3N)
  105.  
  106. NNNNOOOOTTTTEEEESSSS
  107.      The type of address structure passed to _rrrr_eeee_cccc_vvvv depends on the address
  108.      family.  UNIX domain sockets (address family _AAAA_FFFF______UUUU_NNNN_IIII_XXXX) require a
  109.      _ssss_oooo_cccc_kkkk_eeee_tttt_aaaa_dddd_dddd_rrrr______uuuu_nnnn structure as defined in _ssss_yyyy_ssss_////_uuuu_nnnn_...._hhhh; Internet domain sockets
  110.      (address family _AAAA_FFFF______IIII_NNNN_EEEE_TTTT) require a _ssss_oooo_cccc_kkkk_aaaa_dddd_dddd_rrrr______iiii_nnnn structure as defined in
  111.      _nnnn_eeee_tttt_iiii_nnnn_eeee_tttt_////_iiii_nnnn_...._hhhh.  Other address families may require other structures.  Use
  112.      the structure appropriate to the address family; cast the structure
  113.      address to a generic _cccc_aaaa_dddd_dddd_rrrr______tttt in the call to _rrrr_eeee_cccc_vvvv and pass the size of the
  114.      structure in the _f_r_o_m_l_e_n argument.
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.                                                                         PPPPaaaaggggeeee 2222
  128.  
  129.  
  130.  
  131.